﻿Public Class DataListMenu3
    Inherits System.Web.UI.Page

    Protected mDtPermissoes As DataTable

    Protected Sub EncheMenu()
        Try
            Me.BuscaPermissoesUsuarioNoPortal()
            Me.EncheMenuPerfil()
            Me.hideMenu.Visible = True
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BuscaPermissoesUsuarioNoPortal()
        'Dim obj As New ORMAdminDLL.clsORMTipoPerfilUsuarios()
        'Try
        '    Dim PerfilNomePortalPermissao As String = "SaudeFOZ"
        '    mDtPermissoes = obj.BuscaPermissoesUsuarioNoPortal(764, PerfilNomePortalPermissao)
        'Finally
        '    obj.Dispose()
        '    obj = Nothing
        'End Try
    End Sub

    Private Sub EncheMenuPerfil()

        Dim Aux As Integer = 0
        Me.divMenu.InnerHtml = "<ul class='theMenu'>"
        For Each dtRow As DataRow In Me.mDtPermissoes.Rows()
            If CInt(dtRow("TipoPerfilId")) <> Aux Then
                Me.divMenu.InnerHtml &= "<li><h3 class='head'><a href='#'>" & dtRow("TipPerfNome").ToString & "</a></h3>"
                'Me.EncheMenuTipoFormulario(CInt(dtRow("TipoPerfilId")))

                Me.EncheMenuFormularios(CInt(dtRow("TipoPerfilId")))
                Me.divMenu.InnerHtml &= "</li>"
                Aux = CInt(dtRow("TipoPerfilId"))
            End If
        Next
        Me.divMenu.InnerHtml &= "</ul>"

    End Sub

    'Private Sub EncheMenuTipoFormulario(ByVal tipoPerfilID As Integer)

    '    Me.divMenu.InnerHtml &= "<ul class='xtraMenu'>"
    '    Dim Aux As String = ""
    '    For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & tipoPerfilID)
    '        If dtRow("FormTipo") <> Aux Then
    '            Me.divMenu.InnerHtml &= "<li><h4 class='head'><a href='#'>" & dtRow("FormTipo") & "</a></h4>"
    '            Me.EncheMenuFormularios(tipoPerfilID, dtRow("FormTipo").ToString)
    '            Me.divMenu.InnerHtml &= "</li>"
    '            Aux = dtRow("FormTipo")
    '        End If
    '    Next
    '    Me.divMenu.InnerHtml &= "</ul>"

    'End Sub

    Private Sub EncheMenuFormularios(ByVal tipoPerfilID As Integer)

        Me.divMenu.InnerHtml &= "<ul>"
        Dim Aux As Integer = 0
        For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & tipoPerfilID)
            If CInt(dtRow("FormularioID")) <> Aux Then
                Me.divMenu.InnerHtml &= "<li><a href='" & dtRow("PageEndereco") & "'>" & dtRow("FormNmMenu") & "</a></li>"
                Aux = CInt(dtRow("FormularioID"))
            End If
        Next
        Me.divMenu.InnerHtml &= "</ul>"

    End Sub

    Protected Sub uia_Click(ByVal sender As Object, ByVal e As EventArgs) Handles uia.Click
        Me.EncheMenu()
    End Sub

End Class